package com.demo.behavioral.memento;

public class GameRole {
	
	private int power;
	
	private int aggressivity; 
	
    public int getPower() {
		return power;
	}

	public void setPower(int power) {
		this.power = power;
	}

	public int getAggressivity() {
		return aggressivity;
	}

	public void setAggressivity(int aggressivity) {
		this.aggressivity = aggressivity;
	} 
    
    public void show(){
        System.out.println("体力:"+power);
        System.out.println("攻击力:"+aggressivity);
    }
    
    public void fightBoss(){
    	this.power=0;
    	this.aggressivity=0;
    }
    
    public GameRoleMemento getGameRoleMemento(){
    	//将GameRole的属性、属性值拷贝到新的GameRoleMemento对象中
    	GameRoleMemento gameRoleMemento = new GameRoleMemento();
    	gameRoleMemento.setPower(this.power);
    	gameRoleMemento.setAggressivity(this.aggressivity);
        return gameRoleMemento;
    }
    
    public GameRole getGameRole(GameRoleMemento gameRoleMemento){ 
    	//将GameRoleMemento的属性、属性值拷贝到新的GameRole对象中
    	GameRole gameRole = new GameRole();
    	gameRole.setPower(gameRoleMemento.getPower());
    	gameRole.setAggressivity(gameRoleMemento.getAggressivity());
        return gameRole;
    }

}
